<template>
  <div class="version-page">
    <!-- 页面头部 -->
    <div class="page-header">
      <div class="header-container">
        <span class="section-badge">版本历程</span>
        <h1 class="page-title">产品版本变迁</h1>
        <p class="page-subtitle">见证球球助手的每一次进步与创新</p>
      </div>
    </div>

    <!-- 版本时间线 -->
    <div class="timeline-container">
      <div class="timeline-content">
        <div v-for="(majorVersion, majorIndex) in reversedVersionData" :key="majorIndex" class="major-version-section">
          <!-- 大版本标题 -->
          <div class="major-version-header">
            <div class="version-number">V{{ versionData.length - majorIndex }}.0</div>
            <div class="version-line"></div>
          </div>

          <!-- 次版本列表 -->
          <div class="minor-versions">
            <div v-for="(minorVersion, minorIndex) in majorVersion" :key="minorIndex" class="minor-version-card">
              <div class="version-info">
                <div class="version-tag">V{{ majorIndex + 1 }}.{{ majorVersion.length - minorIndex - 1 }}.0</div>
                <div class="release-date">{{ minorVersion[0] }}</div>
              </div>

              <!-- 更新内容 -->
              <div class="update-list">
                <div v-for="(update, updateIndex) in getUpdateItems(minorVersion)" :key="updateIndex" class="update-item">
                  <div class="update-version">
                    V{{ majorIndex + 1 }}.{{ majorVersion.length - minorIndex - 1 }}.{{ getUpdateItems(minorVersion).length - updateIndex }}
                  </div>
                  <div class="update-content">{{ update }}</div>
                  <div class="update-icon">
                    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                      <path d="M12 2L15.09 8.26L22 9L17 14L18.18 21L12 17.77L5.82 21L7 14L2 9L8.91 8.26L12 2Z" fill="currentColor" />
                    </svg>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 页面底部统计 -->
    <div class="stats-section">
      <div class="stats-container">
        <div class="stat-item">
          <div class="stat-number">{{ getTotalVersions() }}</div>
          <div class="stat-label">总版本数</div>
        </div>
        <div class="stat-item">
          <div class="stat-number">{{ getTotalFeatures() }}</div>
          <div class="stat-label">新增功能</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import versionArray from '@/utils/package.version';

// SEO设置
useSEO({
  title: '版本变迁 - 球球助手产品更新历程',
  description: '查看球球助手的版本更新历史，了解产品功能迭代过程和每个版本的新增特性。',
  keywords: '球球助手,版本更新,产品变迁,功能迭代,更新日志,足球数据平台',
});

const versionData = ref(versionArray);

// 反转版本数据，让最新版本在前面
const reversedVersionData = computed(() => {
  return versionData.value.map((majorVersion, majorIndex) => {
    // 反转次版本顺序，让日期最新的在前面
    return [...majorVersion].reverse().map((minorVersion, minorIndex) => {
      // 保持更新内容顺序不变
      return [...minorVersion];
    });
  });
});

// 获取更新内容（过滤掉日期项并反转顺序）
const getUpdateItems = (minorVersion: string[]) => {
  return minorVersion.slice(1).reverse(); // 跳过第一项的日期并反转顺序
};

// 获取总版本数
const getTotalVersions = () => {
  let total = 0;
  versionData.value.forEach((major) => {
    major.forEach((minor) => {
      total += minor.length - 1; // 减去日期项
    });
  });
  return total;
};

// 获取总功能数
const getTotalFeatures = () => {
  return getTotalVersions();
};
</script>

<style scoped>
.version-page {
  min-height: 100vh;
  background: var(--bg-primary-gradient);
  padding-bottom: 2rem;
}

.page-header {
  background: transparent;
  padding: 4rem 2rem 3rem;
  position: relative;
  overflow: hidden;
}

.page-header::before {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.1) 0%, rgba(249, 115, 22, 0.1) 100%);
  border-radius: 50%;
  top: -150px;
  right: -100px;
  z-index: 0;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  text-align: center;
  position: relative;
  z-index: 1;
}

.section-badge {
  display: inline-block;
  background-color: rgba(234, 179, 8, 0.15);
  color: var(--primary-gold);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  margin-bottom: 1rem;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.page-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: white;
  margin-bottom: 1rem;
  background: var(--bg-secondary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.page-subtitle {
  font-size: 1.125rem;
  color: rgba(255, 255, 255, 0.7);
  max-width: 600px;
  margin: 0 auto;
}

.timeline-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem;
}

.major-version-section {
  margin-bottom: 4rem;
}

.major-version-header {
  display: flex;
  align-items: center;
  margin-bottom: 2rem;
  gap: 1rem;
}

.version-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-gold);
  background: rgba(234, 179, 8, 0.15);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-full);
  min-width: 120px;
  text-align: center;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.version-line {
  flex: 1;
  height: 2px;
  background: linear-gradient(to right, var(--primary-gold), transparent);
}

.minor-versions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 1.5rem;
  margin-left: 2rem;
}

.minor-version-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-glass);
  border: 1px solid var(--glass-border);
  transition: all var(--transition-normal);
  position: relative;
  height: 400px;
  display: flex;
  flex-direction: column;
}

.minor-version-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-primary);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(234, 179, 8, 0.4);
}

.minor-version-card::before {
  content: '';
  position: absolute;
  left: -1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  background: var(--primary-gold);
  border-radius: 50%;
  box-shadow:
    0 0 0 4px var(--dark-slate),
    0 0 0 6px var(--primary-gold);
}

.version-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.version-tag {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary-gold);
  background: rgba(234, 179, 8, 0.15);
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.release-date {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.6);
}

.update-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
  overflow-y: auto;
  padding-right: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(234, 179, 8, 0.3) transparent;
}

.update-list::-webkit-scrollbar {
  width: 6px;
}

.update-list::-webkit-scrollbar-track {
  background: transparent;
}

.update-list::-webkit-scrollbar-thumb {
  background: rgba(234, 179, 8, 0.3);
  border-radius: 3px;
}

.update-list::-webkit-scrollbar-thumb:hover {
  background: rgba(234, 179, 8, 0.5);
}

.update-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(234, 179, 8, 0.05);
  border-radius: var(--radius-md);
  border: 1px solid rgba(234, 179, 8, 0.1);
  transition: all var(--transition-fast);
}

.update-item:hover {
  background: rgba(234, 179, 8, 0.1);
  border-color: rgba(234, 179, 8, 0.2);
}

.update-version {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary-gold);
  background: rgba(234, 179, 8, 0.15);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  min-width: 60px;
  text-align: center;
  flex-shrink: 0;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.update-content {
  flex: 1;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.5;
}

.update-icon {
  color: var(--primary-gold);
  margin-top: 0.125rem;
  flex-shrink: 0;
}

.stats-section {
  background: transparent;
  padding: 3rem 2rem;
  margin-top: 2rem;
}

.stats-container {
  max-width: 800px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  text-align: center;
}

.stat-item {
  padding: 1.5rem;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: var(--radius-xl);
  border: 1px solid var(--glass-border);
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-glass);
}

.stat-item:hover {
  transform: translateY(-5px);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(234, 179, 8, 0.4);
  box-shadow: var(--shadow-primary);
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  background: var(--bg-secondary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
}

.stat-label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 1rem;
  font-weight: 500;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .page-title {
    font-size: 2rem;
  }

  .minor-versions {
    grid-template-columns: 1fr;
    margin-left: 1rem;
  }

  .version-number {
    font-size: 1.5rem;
    min-width: 100px;
  }

  .update-item {
    flex-direction: column;
    gap: 0.5rem;
  }

  .update-version {
    align-self: flex-start;
  }
}

@media (max-width: 480px) {
  .timeline-container {
    padding: 2rem 1rem;
  }

  .minor-version-card {
    padding: 1rem;
  }

  .version-info {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }
}
</style>
